<?php

require_once (APPLICATION_PATH
        . DIRECTORY_SEPARATOR . 'modules'
        . DIRECTORY_SEPARATOR . 'report'
        . DIRECTORY_SEPARATOR . 'public'
        . DIRECTORY_SEPARATOR . 'models'
        . DIRECTORY_SEPARATOR . 'Daily.php');

class Zend_View_Helper_VisitorCountModule {

    public $view;

    public function setView($view) {
        $this->view = $view;
    }

    public function visitorCountModule($position) {
        $model = new Daily();
        $today = date('y-m-d');
        $row = $model->fetchRow($model->select()->where('date=?', $today));
        if ($row) {
            $this->view->today = $row->visit;
        } else {
            $this->view->today = 0;
        }
        $this->view->total = $model->getTotalCount();
        $this->view->placeholder($position)->captureStart();
        echo $this->view->render('visitor_counter.phtml');
        $this->view->placeholder($position)->captureEnd();
    }

}